how to solve by matrix method